from devicetest.aw.OpenHarmony import CommonOH
from devicetest.core.test_case import TestCase, Step

from aw.common import common_setup, common_teardown
from aw.pom import DeskTop


class PreTest_RK3568_Basic_Desktop_0100(TestCase, DeskTop):
    # 预置条件：
    # 烧写目标版本后，正常进入桌面
    # 测试步骤：
    # 反复长按桌面空白处
    # 预期结果：
    # 出现选择桌面编辑项弹窗，无卡死、黑屏、白屏等现象

    def __init__(self, controllers):
        self.TAG = self.__class__.__name__
        TestCase.__init__(self, self.TAG, controllers)

    def setup(self):
        common_setup(self.Phone1)

    def process(self):
        for i in range(1, 6):
            Step('步骤{}.0：长按桌面空白处'.format(i))
            CommonOH.click(self.Phone1, **self.center, mode='LONG')
            Step('预期结果{}.0：出现选择桌面编辑项弹窗，无卡死、黑屏、白屏等现象'.format(i))
            CommonOH.wait(self.Phone1, 1)
            CommonOH.checkIfTextExist(self.Phone1, '选择桌面编辑项')
            Step('步骤{}.1：点击取消'.format(i))
            CommonOH.touchByText(self.Phone1, '取消')

    def teardown(self):
        common_teardown(self.Phone1)
